-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(syntax-highlight): add nolint aliases for html/js #7017
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I give my approval on any kind of nolint marker. I don't care about which—we can always migrate later with a trivial search&replace. This seems to be the easiest for now, without forking all the parsers.
Co-authored-by: Onkar Ruikar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but as jsnolint
looks like jsonlint
with a typo, any chance of adding a hyphen (js-nolint
, html-nolint
)? Otherwise folks will regularly have to look twice when encountering occurrences of jsnolint
.
If we are willing to reconsider the strategy I would like to suggest using
Cons:
If "forking all the parsers" hear means modifying linters' codes to make them recognize Every linter supports at least two way of linting things: We can write a wrapper around, for example ESLint, linter where it'll read provided .md file and pickup code blocks with the language and without This will also solve the problem of linting the live samples without adjusting exiting content. We use same logic which yari uses to combine live sample snippets and feed the whole code to the linter. The same wrapper can support any language linters in future. All we have to do is import it's library and use the API. This way we can also lint code blocks in different sections with different sets of rules. For example syntax sections with less strict rules, live samples and example section code with almost all the rules. Forgive me if I've repeated things by being out of context. |
I'm ok with If we can make We still need to gather more experience to reach a point where Prettier can be run automatically. Also, it was pointed out earlier by Josh-Cena, if we go swap Let's wait for more feedback here. (Meanwhile, I'll change the name) |
I have no idea if tweaking the Prettier parser is simpler option. But making Prettier understand our live samples is certainly not easy. Unless we are realigning our content. |
IMO this ☝️ is the main blocker, so I wonder what is more important:
|
Having syntax highlight is not a big deal in the short term, unless we plan to use And yes, |
I think that the ideal solution would be: As info strings are standard Markdown (CommonMark at least), we should submit upstream an improvement to Prettier (or other linters), allowing the tool to ignore fences followed by specific info strings (configurable). Then we could do the following:
or even
That way:
Should we try this? If we agree, we can contact the maintainer ahead of the work to get his opinion. I've not looked if the parser already detects info strings but if so, it shouldn't be too complex. |
Prettier does receive the extra info string from its parser:
The convention is to use first word as a language and rest as extra info (meta). With above knowledge, temporary workaround could be to write a wrapper:
|
How about we merge this PR with hyphens for readability, and migrate to @teoli2003 @Elchi3 @Josh-Cena @OnkarRuikar Please leave a 👍 if you agree and 👎 if you have objections. |
Strong agree—let's not block this for some far future visions. |
Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
* Tag syntax code blocks with js-nolint, part 9 Adding to #19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/ndefrecord/torecords/index.md * Update files/en-us/web/api/nodelist/entries/index.md * Update files/en-us/web/api/nodelist/foreach/index.md * Update files/en-us/web/api/nodelist/keys/index.md * Update files/en-us/web/api/nodelist/values/index.md * Update files/en-us/web/api/presentationrequest/start/index.md * Update files/en-us/web/api/relativeorientationsensor/relativeorientationsensor/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 10 Adding to #19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/rtcicetransport/getremoteparameters/index.md * Update files/en-us/web/api/rtcpeerconnection/addstream/index.md * Update files/en-us/web/api/rtcpeerconnection/close/index.md * Update files/en-us/web/api/rtcpeerconnection/getidentityassertion/index.md * Update files/en-us/web/api/rtcpeerconnection/getreceivers/index.md * Update files/en-us/web/api/rtcpeerconnection/getsenders/index.md * Update files/en-us/web/api/rtcpeerconnection/removestream/index.md * Update files/en-us/web/api/rtcpeerconnection/removetrack/index.md * Update files/en-us/web/api/rtcrtpsender/replacetrack/index.md * Update files/en-us/web/api/selection/setbaseandextent/index.md * Update files/en-us/web/api/serviceworkercontainer/startmessages/index.md * Update files/en-us/web/api/storagemanager/persist/index.md * Update files/en-us/web/api/storagemanager/persisted/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 11 Adding to #19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/svgpoint/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 12 Adding to #19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/window/showdirectorypicker/index.md * Update files/en-us/web/api/webgl_multi_draw/multidrawarraysinstancedwebgl/index.md * Update files/en-us/web/api/webgl_multi_draw/multidrawarrayswebgl/index.md * Update files/en-us/web/api/webgl_multi_draw/multidrawelementsinstancedwebgl/index.md * Update files/en-us/web/api/webgl_multi_draw/multidrawelementswebgl/index.md * Update files/en-us/web/api/webglrenderingcontext/attachshader/index.md * Update files/en-us/web/api/webglrenderingcontext/detachshader/index.md * Update files/en-us/web/api/window/showdirectorypicker/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 13 Adding to #19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/xrwebgllayer/antialias/index.md * Update files/en-us/web/api/xrwebgllayer/getnativeframebufferscalefactor/index.md * Update files/en-us/web/api/xrwebgllayer/getnativeframebufferscalefactor/index.md * Update files/en-us/web/http/proxy_servers_and_tunneling/proxy_auto-configuration_pac_file/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
Adding to #19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
Adding to #19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
Adding to #19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
For anyone interested in editor highlighting, I found this gem: https://github.com/mjbvz/vscode-fenced-code-block-grammar-injection-example We can build a VS Code extension to support more language tags even if we don't migrate to using metastring. |
Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
- Updating example-bad code blocks with the new tag. Refer: mdn/yari#7017
* Tag `example-bad` blocks with html-nolint - Updating example-bad code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/learn/accessibility/html/index.md * Update files/en-us/learn/accessibility/html/index.md * Removed suggested no nolints Co-authored-by: Jean-Yves Perrier <[email protected]> * remove a trailing space * Update files/en-us/learn/accessibility/html/index.md * Update files/en-us/learn/accessibility/html/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
* Tag syntax code blocks with js-nolint, part 6 Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/filereadersync/readasarraybuffer/index.md * Update files/en-us/web/api/filesystemdirectoryhandle/entries/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 7 Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/htmlvideoelement/msstereo3drendermode/index.md * Update files/en-us/web/api/filesystemfilehandle/createwritable/index.md * Update files/en-us/web/api/filesystemdirectoryhandle/resolve/index.md * Update files/en-us/web/api/filesystemdirectoryhandle/values/index.md * Update files/en-us/web/api/filesystemfilehandle/getfile/index.md * Update files/en-us/web/api/filesystemhandle/querypermission/index.md * Update files/en-us/web/api/htmlformelement/reportvalidity/index.md * Update files/en-us/web/api/filesystemhandle/requestpermission/index.md * Update files/en-us/web/api/filesystemwritablefilestream/seek/index.md * Update files/en-us/web/api/filesystemwritablefilestream/truncate/index.md * Update files/en-us/web/api/htmlcollection/nameditem/index.md * Update files/en-us/web/api/htmlmediaelement/mscleareffects/index.md * Update files/en-us/web/api/htmlvideoelement/mssetvideorectangle/index.md * Update files/en-us/web/api/htmlvideoelement/msstereo3dpackingmode/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 8 Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/ndefreader/write/index.md * Update files/en-us/web/api/ndefrecord/ndefrecord/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 9 Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/ndefrecord/torecords/index.md * Update files/en-us/web/api/nodelist/entries/index.md * Update files/en-us/web/api/nodelist/foreach/index.md * Update files/en-us/web/api/nodelist/keys/index.md * Update files/en-us/web/api/nodelist/values/index.md * Update files/en-us/web/api/presentationrequest/start/index.md * Update files/en-us/web/api/relativeorientationsensor/relativeorientationsensor/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 10 Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/rtcicetransport/getremoteparameters/index.md * Update files/en-us/web/api/rtcpeerconnection/addstream/index.md * Update files/en-us/web/api/rtcpeerconnection/close/index.md * Update files/en-us/web/api/rtcpeerconnection/getidentityassertion/index.md * Update files/en-us/web/api/rtcpeerconnection/getreceivers/index.md * Update files/en-us/web/api/rtcpeerconnection/getsenders/index.md * Update files/en-us/web/api/rtcpeerconnection/removestream/index.md * Update files/en-us/web/api/rtcpeerconnection/removetrack/index.md * Update files/en-us/web/api/rtcrtpsender/replacetrack/index.md * Update files/en-us/web/api/selection/setbaseandextent/index.md * Update files/en-us/web/api/serviceworkercontainer/startmessages/index.md * Update files/en-us/web/api/storagemanager/persist/index.md * Update files/en-us/web/api/storagemanager/persisted/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 11 Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/svgpoint/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 12 Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/window/showdirectorypicker/index.md * Update files/en-us/web/api/webgl_multi_draw/multidrawarraysinstancedwebgl/index.md * Update files/en-us/web/api/webgl_multi_draw/multidrawarrayswebgl/index.md * Update files/en-us/web/api/webgl_multi_draw/multidrawelementsinstancedwebgl/index.md * Update files/en-us/web/api/webgl_multi_draw/multidrawelementswebgl/index.md * Update files/en-us/web/api/webglrenderingcontext/attachshader/index.md * Update files/en-us/web/api/webglrenderingcontext/detachshader/index.md * Update files/en-us/web/api/window/showdirectorypicker/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
* Tag syntax code blocks with js-nolint, part 13 Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/web/api/xrwebgllayer/antialias/index.md * Update files/en-us/web/api/xrwebgllayer/getnativeframebufferscalefactor/index.md * Update files/en-us/web/api/xrwebgllayer/getnativeframebufferscalefactor/index.md * Update files/en-us/web/http/proxy_servers_and_tunneling/proxy_auto-configuration_pac_file/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
Adding to mdn#19177 - Updating syntax code blocks with the new tag. Refer: mdn/yari#7017
* Tag `example-bad` blocks with html-nolint - Updating example-bad code blocks with the new tag. Refer: mdn/yari#7017 * Update files/en-us/learn/accessibility/html/index.md * Update files/en-us/learn/accessibility/html/index.md * Removed suggested no nolints Co-authored-by: Jean-Yves Perrier <[email protected]> * remove a trailing space * Update files/en-us/learn/accessibility/html/index.md * Update files/en-us/learn/accessibility/html/index.md Co-authored-by: Jean-Yves Perrier <[email protected]>
This PR replaces the Prism alias for
jssyntax
withjsnolint
, and addshtmlnolint
.jssyntax
was added in #6682, but we decided not to use it as it is too semantic, and we wanted to avoid a potentially long list of semantic aliases.The idea is to have such code blocks styled by Prism with the right color scheme but skipped when linter run, like Markdownlint, or Prettier, as these blocks are not valid (for example our syntax box), or should not be formatted by linters (like examples of invalid code, or TML templates that require an unusual alignment).
In a meeting a couple of weeks ago, I understood that we have a consensus on these two names (we need
htmlnolint
for some templates in the Learning Area).So, first: do we have a consensus? @Rumyra @wbamberg @Josh-Cena @Elchi3 can you approve to mark your approval?
Once this is confirmed, let's ping the devs for a review.
Thank you all! (Consensus-decision making is sometimes a hard task, but it leads to much better solutions!)